<?php

namespace App\Http\Controllers\Client;

use App\Services\CarryApplyService;
use App\Services\RedPackService;
use App\Utils\ApiResponse;
use Illuminate\Http\Request;
use EasyWeChat\Factory;

class CarryController extends ClientBase
{
    /**
     * 提现申请
     */
    public function apply(Request $request)
    {
        try {
            $data = $request->decrypted_data;
            if (!isset($data->money) || (float) $data->money <= 0) {
                ApiResponse::fail("提现金额不合法");
            }
            $carryApplyService = new CarryApplyService();
            $applyRes = $carryApplyService->apply(
                $this->currentUser->id,
                (float) $data->money
            );
            if ($applyRes) {
                ApiResponse::success();
            }
            ApiResponse::fail();
        } catch (\Exception $e) {
            ApiResponse::fail();
        }
    }
}
